package com.bdqn.t320.ch06.controller;


import com.bdqn.t320.ch06.entity.Dept;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;


@Api(tags = "用户管理")
@RequestMapping("/swagger")
@RestController
public class SwaggerExampleController {

    @RequestMapping("/ceshi/{id}")
    public Object ceshi(@PathVariable(value = "id") Integer id) {
        Dept dept = new Dept();
        dept.setId(id);
        dept.setDeptName("财务部");
        return dept;
    }


    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",//参数名字
                    value = "用户名id",//参数的描述
                    required = true,//是否必须传入
                    dataType = "int",
                    //paramType定义参数传递类型：有path,query,body,form,header
                    paramType = "query"
            )
    })
    @GetMapping("/ceshi1/{id}")
    public Object ceshi1(@PathVariable(value = "id") Integer id) {
        Dept dept = new Dept();
        dept.setId(id);
        dept.setDeptName("财务部");
        return dept;
    }

    @PostMapping("/ceshi2/{id}")
    public Object ceshi2(@PathVariable(value = "id") Integer id) {
        Dept dept = new Dept();
        dept.setId(id);
        dept.setDeptName("财务部");
        return dept;
    }

    @ApiOperation(value = "测试RequestBody",notes = "用户测试notes")
    @PostMapping("/ceshi3")
    public Object ceshi3(@RequestBody Dept dept) {
        return dept;
    }

    @GetMapping("/ceshi4")
    public Object ceshi4(@RequestBody Dept dept) {
        return dept;
    }

    @GetMapping("/ceshi5")
    public Object ceshi5(Dept dept) {
        return dept;
    }

    @PostMapping("/ceshi6")
    public Object ceshi6(Dept dept) {
        return dept;
    }

}
